-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
更新毎日解题06月04日 #24
更新毎日解题06月04日 #24
Conversation
templates/daily/2019-06-04.md
Outdated
Return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1. | ||
``` | ||
## 参考答案 | ||
`1.暴力求解,时间复杂度O(n^2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成:
1.暴力求解,时间复杂度O(n^2)
我们可以一次遍历gas,对于每一个gas我们依次遍历后面的gas,计算remian,如果remain一旦小于0,就说明不行,我们继续遍历下一个
这种格式
templates/daily/2019-06-04.md
Outdated
retirn -1; | ||
``` | ||
|
||
`2.比较巧妙的方法,时间复杂度是O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
||
`2.比较巧妙的方法,时间复杂度是O(n) | ||
这个方法基于两点: | ||
2-1:如果站点i到达站点j走不通,那么从i到j之间的站点(比如k)出发一定都走不通。前提i(以及i到k之间)不会拖累总体(即remain >= 0)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成:
这个方法基于两点:
(注意这里有一个空行)
2-1:如果站点i到达站点j走不通,那么从i到j之间的站点(比如k)出发一定都走不通。前提i(以及i到k之间)不会拖累总体(即remain >= 0)。
templates/daily/2019-06-04.md
Outdated
`2.比较巧妙的方法,时间复杂度是O(n) | ||
这个方法基于两点: | ||
2-1:如果站点i到达站点j走不通,那么从i到j之间的站点(比如k)出发一定都走不通。前提i(以及i到k之间)不会拖累总体(即remain >= 0)。 | ||
2-2:如果cost总和大于gas总和,无论如何也无法走到终点,这个比较好理解。因此假如存在一个站点出发能够到达终点,其实就说明cost总和一定小于等于gas总和` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
No description provided.